//package com.blr.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.authentication.AuthenticationManager;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
//import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
//import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
//import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
//
////自定义授权服务器配置
//@Configuration
//@EnableAuthorizationServer //指定当前应用为授权服务器
//public class InMemoryAuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
//
//    private final PasswordEncoder passwordEncoder;
//
//    private final UserDetailsService userDetailsService;
//
//    private final AuthenticationManager authenticationManager;
//
//    @Autowired
//    public InMemoryAuthorizationServerConfig(PasswordEncoder passwordEncoder, UserDetailsService userDetailsService, AuthenticationManager authenticationManager){
//        this.passwordEncoder = passwordEncoder;
//        this.userDetailsService = userDetailsService;
//        this.authenticationManager = authenticationManager;
//    }
//
//    //用来配置授权服务器可以为哪些客户端授权 client_id secret redirect_url 使用哪种授权模式
//    @Override
//    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
//        System.out.println(passwordEncoder.encode("secret"));
//        clients.inMemory()
//                .withClient("client")
//                .secret(passwordEncoder.encode("secret"))
//                .redirectUris("http://www.baidu.com")
//                .authorizedGrantTypes("authorization_code","refresh_token","implicit","password","client_credentials") //授权服务器支持的模式 仅支持授权码模式 refresh_token 刷新令牌 implicit 简单 password 密码 client_credentials 客户端
//                .scopes("read:user"); //令牌允许获取的资源权限
//    }
//
//    //配置授权服务器使用哪个userDetailsService
//    @Override
//    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
//        endpoints.userDetailsService(userDetailsService); //注入userDetailsService
//        endpoints.authenticationManager(authenticationManager); //注入authenticationManager
//    }
//
//    //授权码这种模式：
//    // 1.请求用户是否授权 /oauth/authorize
//    // 完整路径 http://localhost:8080/oauth/authorize?client_id=client&response_type=code&redirect_uri=http://www.baidu.com
//    // 2.授权之后根据获取得授权码获取令牌 /oauth/token id secret redirectUri 授权类型： authorization_code
//    // 完整路径 curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d  'grant_type=authorization_code&code=YTOpTp&redirect_uri=http://www.baidu.com' "http://client:secret@localhost:8080/oauth/token"
//    //postman测试 post 路径：http://client:secret@localhost:8080/oauth/token 参数 'grant_type=authorization_code&code=YTOpTp&redirect_uri=http://www.baidu.com'
//    //3.支持令牌刷新 /oauth/token id secret 授权类型： refresh_token 刷新的令牌：refresh_token
//    //完整路径：
//
//}
